/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package mywebapp.dao.impl;

import mywebapp.MywebappPackage;
import mywebapp.dao.Champ;
import mywebapp.dao.DaoFactory;
import mywebapp.dao.DaoPackage;
import mywebapp.dao.ETypeSimple;
import mywebapp.dao.Entity;
import mywebapp.dao.Type;
import mywebapp.dao.TypeEntity;
import mywebapp.dao.TypeSimple;
import mywebapp.dao.util.DaoValidator;
import mywebapp.dao.TypeEntity;

import mywebapp.impl.MywebappPackageImpl;
import mywebapp.webpage.WebpagePackage;
import mywebapp.webpage.impl.WebpagePackageImpl;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;

import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.impl.EPackageImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Package</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class DaoPackageImpl extends EPackageImpl implements DaoPackage {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EClass entityEClass = null;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EClass champEClass = null;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EClass typeEClass = null;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EClass typeEntityEClass = null;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EClass typeSimpleEClass = null;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private EEnum eTypeSimpleEEnum = null;

	/**
	 * Creates an instance of the model <b>Package</b>, registered with
	 * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
	 * package URI value.
	 * <p>Note: the correct way to create the package is via the static
	 * factory method {@link #init init()}, which also performs
	 * initialization of the package, or returns the registered package,
	 * if one already exists.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see org.eclipse.emf.ecore.EPackage.Registry
	 * @see mywebapp.dao.DaoPackage#eNS_URI
	 * @see #init()
	 * @generated
	 */
	private DaoPackageImpl() {
		super(eNS_URI, DaoFactory.eINSTANCE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private static boolean isInited = false;

	/**
	 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
	 * 
	 * <p>This method is used to initialize {@link DaoPackage#eINSTANCE} when that field is accessed.
	 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #eNS_URI
	 * @see #createPackageContents()
	 * @see #initializePackageContents()
	 * @generated
	 */
	public static DaoPackage init() {
		if (isInited) return (DaoPackage)EPackage.Registry.INSTANCE.getEPackage(DaoPackage.eNS_URI);

		// Obtain or create and register package
		DaoPackageImpl theDaoPackage = (DaoPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof DaoPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new DaoPackageImpl());

		isInited = true;

		// Obtain or create and register interdependencies
		MywebappPackageImpl theMywebappPackage = (MywebappPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(MywebappPackage.eNS_URI) instanceof MywebappPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(MywebappPackage.eNS_URI) : MywebappPackage.eINSTANCE);
		WebpagePackageImpl theWebpagePackage = (WebpagePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(WebpagePackage.eNS_URI) instanceof WebpagePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(WebpagePackage.eNS_URI) : WebpagePackage.eINSTANCE);

		// Create package meta-data objects
		theDaoPackage.createPackageContents();
		theMywebappPackage.createPackageContents();
		theWebpagePackage.createPackageContents();

		// Initialize created meta-data
		theDaoPackage.initializePackageContents();
		theMywebappPackage.initializePackageContents();
		theWebpagePackage.initializePackageContents();

		// Register package validator
		EValidator.Registry.INSTANCE.put
			(theDaoPackage, 
			 new EValidator.Descriptor() {
				 public EValidator getEValidator() {
					 return DaoValidator.INSTANCE;
				 }
			 });

		// Mark meta-data to indicate it can't be changed
		theDaoPackage.freeze();

  
		// Update the registry and return the package
		EPackage.Registry.INSTANCE.put(DaoPackage.eNS_URI, theDaoPackage);
		return theDaoPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EClass getEntity() {
		return entityEClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EAttribute getEntity_Name() {
		return (EAttribute)entityEClass.getEStructuralFeatures().get(0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getEntity_Champs() {
		return (EReference)entityEClass.getEStructuralFeatures().get(1);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EClass getChamp() {
		return champEClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EAttribute getChamp_Name() {
		return (EAttribute)champEClass.getEStructuralFeatures().get(0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EAttribute getChamp_IsList() {
		return (EAttribute)champEClass.getEStructuralFeatures().get(1);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getChamp_Type() {
		return (EReference)champEClass.getEStructuralFeatures().get(2);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getChamp_Entity() {
		return (EReference)champEClass.getEStructuralFeatures().get(3);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EClass getType() {
		return typeEClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EClass getTypeEntity() {
		return typeEntityEClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EReference getTypeEntity_Type() {
		return (EReference)typeEntityEClass.getEStructuralFeatures().get(0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EClass getTypeSimple() {
		return typeSimpleEClass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EAttribute getTypeSimple_Type() {
		return (EAttribute)typeSimpleEClass.getEStructuralFeatures().get(0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EEnum getETypeSimple() {
		return eTypeSimpleEEnum;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DaoFactory getDaoFactory() {
		return (DaoFactory)getEFactoryInstance();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private boolean isCreated = false;

	/**
	 * Creates the meta-model objects for the package.  This method is
	 * guarded to have no affect on any invocation but its first.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void createPackageContents() {
		if (isCreated) return;
		isCreated = true;

		// Create classes and their features
		entityEClass = createEClass(ENTITY);
		createEAttribute(entityEClass, ENTITY__NAME);
		createEReference(entityEClass, ENTITY__CHAMPS);

		champEClass = createEClass(CHAMP);
		createEAttribute(champEClass, CHAMP__NAME);
		createEAttribute(champEClass, CHAMP__IS_LIST);
		createEReference(champEClass, CHAMP__TYPE);
		createEReference(champEClass, CHAMP__ENTITY);

		typeEClass = createEClass(TYPE);

		typeEntityEClass = createEClass(TYPE_ENTITY);
		createEReference(typeEntityEClass, TYPE_ENTITY__TYPE);

		typeSimpleEClass = createEClass(TYPE_SIMPLE);
		createEAttribute(typeSimpleEClass, TYPE_SIMPLE__TYPE);

		// Create enums
		eTypeSimpleEEnum = createEEnum(ETYPE_SIMPLE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private boolean isInitialized = false;

	/**
	 * Complete the initialization of the package and its meta-model.  This
	 * method is guarded to have no affect on any invocation but its first.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void initializePackageContents() {
		if (isInitialized) return;
		isInitialized = true;

		// Initialize package
		setName(eNAME);
		setNsPrefix(eNS_PREFIX);
		setNsURI(eNS_URI);

		// Add supertypes to classes
		typeEntityEClass.getESuperTypes().add(this.getType());
		typeSimpleEClass.getESuperTypes().add(this.getType());

		// Initialize classes and features; add operations and parameters
		initEClass(entityEClass, Entity.class, "Entity", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getEntity_Name(), ecorePackage.getEString(), "name", null, 1, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getEntity_Champs(), this.getChamp(), this.getChamp_Entity(), "champs", null, 1, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(champEClass, Champ.class, "Champ", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getChamp_Name(), ecorePackage.getEString(), "name", null, 1, 1, Champ.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getChamp_IsList(), ecorePackage.getEBoolean(), "isList", "false", 1, 1, Champ.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getChamp_Type(), this.getType(), null, "type", null, 1, 1, Champ.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getChamp_Entity(), this.getEntity(), this.getEntity_Champs(), "entity", null, 1, 1, Champ.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(typeEClass, Type.class, "Type", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);

		initEClass(typeEntityEClass, TypeEntity.class, "TypeEntity", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getTypeEntity_Type(), this.getEntity(), null, "type", null, 1, 1, TypeEntity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(typeSimpleEClass, TypeSimple.class, "TypeSimple", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getTypeSimple_Type(), this.getETypeSimple(), "type", "STRING", 1, 1, TypeSimple.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		// Initialize enums and add enum literals
		initEEnum(eTypeSimpleEEnum, ETypeSimple.class, "ETypeSimple");
		addEEnumLiteral(eTypeSimpleEEnum, ETypeSimple.INT_LITERAL);
		addEEnumLiteral(eTypeSimpleEEnum, ETypeSimple.BIGINT_LITERAL);
		addEEnumLiteral(eTypeSimpleEEnum, ETypeSimple.STRING_LITERAL);
		addEEnumLiteral(eTypeSimpleEEnum, ETypeSimple.FLOAT_LITERAL);
		addEEnumLiteral(eTypeSimpleEEnum, ETypeSimple.DATE_LITERAL);

		// Create annotations
		// http://www.eclipse.org/emf/2002/Ecore
		createEcoreAnnotations();
		// http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
		createPivotAnnotations();
	}

	/**
	 * Initializes the annotations for <b>http://www.eclipse.org/emf/2002/Ecore</b>.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected void createEcoreAnnotations() {
		String source = "http://www.eclipse.org/emf/2002/Ecore";		
		addAnnotation
		  (this, 
		   source, 
		   new String[] {
			 "invocationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
			 "settingDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
			 "validationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"
		   });		
		addAnnotation
		  (entityEClass, 
		   source, 
		   new String[] {
			 "constraints", "not_champ_id not_same_name"
		   });	
	}

	/**
	 * Initializes the annotations for <b>http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot</b>.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected void createPivotAnnotations() {
		String source = "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot";				
		addAnnotation
		  (entityEClass, 
		   source, 
		   new String[] {
			 "not_champ_id", "name <> \'ID\' implies name <> \'id\'",
			 "not_same_name", "champs->forAll(a : Champ, b : Champ | a <> b implies a.name <> b.name)"
		   });
	}

} //DaoPackageImpl
